import 'package:card_swiper/card_swiper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hx/services/app_theme_services.dart';
import 'package:get/get.dart';

import 'share_logic.dart';

class SharePage extends GetView<ShareLogic> {
  const SharePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
     const mainColor=Color.fromRGBO(0, 195, 179, 1);
      return Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.white,
          elevation: 0,
          automaticallyImplyLeading: true,
          iconTheme:const IconThemeData(
              color: Colors.black
          ),
          centerTitle: true,
          title: Text("我的二维码",style: AppThemeServices.textTheme.appBarTitle),
        ),
        body: Column(
          children: [
            Container(
              padding: const EdgeInsets.symmetric(vertical: 10,horizontal: 18),
              color:const Color.fromRGBO(237, 255, 254, 1),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Row(
                        children: [
                          Text("我的邀请码：",style: AppThemeServices.textTheme.h14.copyWith(color: mainColor)),
                          Text("hVVGTH",style: AppThemeServices.textTheme.h24.copyWith(color: mainColor,fontWeight: FontWeight.w900)),
                        ],
                      ),
                      ElevatedButton(
                          onPressed: ()=>{},
                          style: ElevatedButton.styleFrom(
                            primary: mainColor,
                            elevation: 0,
                            padding: EdgeInsets.zero,
                            shadowColor: Colors.transparent,
                            shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(45)),
                            fixedSize: const Size(54.5,28)
                          ),
                          child: Text("复制",style: AppThemeServices.textTheme.h14.copyWith(color: Colors.white)))
                    ],
                  ),
                  Text("(加入燃想 超多福利超值优惠等你来抢)",style: AppThemeServices.textTheme.h14.copyWith(color: mainColor))
                ],
              ),
            ),
            Expanded(child: Obx(()=>Swiper(
              itemBuilder: (context,index){
                return RepaintBoundary(
                   key: controller.globalKeys[index],
                   child: Stack(
                     children: [
                       Positioned(left: 0,right: 0,top: 0,bottom: 0,child: Image.network(controller.brochures[index])),

                     ],
                   ),
                );
              },
              viewportFraction: 0.65,
              scale: 0.9,
              autoplay: false,
              loop: true,
              autoplayDisableOnInteraction: true,
              itemCount: controller.brochures.length,
            ))),
            Padding(
              padding: const EdgeInsets.only(top: 21,bottom: 10,right: 10,left: 10),
              child: Row(
                children: [
                  Expanded(child: OutlinedButton(
                    onPressed: ()=>controller.saveShareImage(),
                    style: OutlinedButton.styleFrom(
                      primary:Colors.white,
                      elevation: 0,
                      fixedSize: const Size(double.infinity, 43),
                      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(45)),
                      side:const BorderSide(color: mainColor,width: 0.5)
                    ),
                    child: Text("保存图片",style: AppThemeServices.textTheme.h16.copyWith(color: mainColor)),
                  )),
                  const SizedBox(width: 10),
                  Expanded(child: ElevatedButton(
                    onPressed: ()=>controller.toShare(),
                    style: ElevatedButton.styleFrom(
                        primary:mainColor,
                        elevation: 0,
                        fixedSize: const Size(double.infinity, 43),
                        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(45)),
                    ),
                    child: Text("分享海报",style: AppThemeServices.textTheme.h16.copyWith(color: Colors.white)),
                  ))
                ],
              ),
            )
          ],
        ),
      );
  }
}
